package org.example.bookshelf_manager.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.bookshelf_manager.model.BookInfo;
import org.example.bookshelf_manager.model.PageResult;

import java.util.List;

/**
 * @ClassName BookMapper
 * @Description TODO
 * @Author ZJX
 * @Date 2024/8/28 8:07
 * @Version 1.0
 */

@Mapper
public interface BookMapper {

    @Insert("insert into book_info (book_name, author, count, price, publish, `status`) " +
            "values (#{bookName}, #{author}, #{count}, #{price}, #{publish}, #{status})")
    Integer insertBook(BookInfo bookInfo);

    @Select("select * from book_info where status != 0  limit #{offset}, #{limit}")
    List<BookInfo> queryBookByPage(Integer offset, Integer limit);


    @Select("select count(1) from book_info") // 获取 表中记录总数
    Integer count();

    @Select("select * from book_info where id = #{bookId}")
    BookInfo queryBookById(Integer bookId);

    Integer updateBookById(BookInfo bookInfo);

    Integer deleteBook(Integer id);

    Integer batchDeleteBook(List<Integer> ids);
}
